package com.sg.business.commons.sidebar.home;

import org.eclipse.swt.widgets.Composite;

import com.mobnut.db.model.DataSetFactory;
import com.sg.business.model.WorkflowSynchronizer;
import com.sg.business.model.dataset.work.ProcessingSidebarSet;
import com.sg.widgets.part.CurrentAccountContext;
import com.sg.widgets.part.sidebar.AbstractTreeViewSideItem;
import com.sg.widgets.viewer.CTreeViewer;

public class WorkProcessingTreeViewSideItem extends AbstractTreeViewSideItem {
	
	private String userId;

	public WorkProcessingTreeViewSideItem() {
		userId = new CurrentAccountContext().getAccountInfo().getConsignerId();
	}

	@Override
	protected String getTreeId() {
		return "work.processing.sidebar";
	}

	@Override
	protected CTreeViewer createTreeViewer(Composite parent) {
		return null;
	}

	@Override
	protected DataSetFactory getDataSetFactory() {
		return new ProcessingSidebarSet();
	}

	@Override
	protected void select(Object po) {
		getViewer().expandToLevel(po, -1);
	}

	@Override
	public void doRefresh() {
		WorkflowSynchronizer synchronizer = new WorkflowSynchronizer();
		synchronizer.synchronizeUserTask(userId);
		super.doRefresh();
	}

}
